package Euler26;

import java.util.*;
import ReusableCode.MathFunctions;

public class ReciprocalCycles {
	public static void main(String[] args) {
		int maxD = 2;
		int max = 0;
		
		for(int d = 2; d <= 1000; d++)
		{
			int len = MathFunctions.numberOfDigits(d);
			int n = 1;
			int count = 0;
			HashSet<Integer> hash = new HashSet<Integer>();
			
			while(!hash.contains(n))
			{
				hash.add(n);
				n = n * ((int) Math.pow(10, len));
				n = n % d;
				count++;
			}
			
			if(count > max)
			{
				max = count;
				maxD = d;
			}
			
			//System.out.println("d is: " + d + ", and the length is: " + count);
		}
		
		System.out.println("d is: " + maxD + ", and the length is: " + max);
	}
}
